<template>
  <div class="dialog">
    <div class="dialog-con complaintDelInfo">
      <div class="com">取消原因</div>
      <div class="confirmshop">
        <div class="reason">
          <el-input type="textarea" :rows="4" v-model="reason"></el-input>
        </div>
        <div class="stockCon">
          <el-button @click="confirm">确认</el-button>
          <el-button @click="cancelStock">取消</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {localStorage} from 'js/localStorage'
  import api from 'js/service'

  export default {
    inject: ['reload'],
    data() {
      return {
        reason: ''
      }
    },
    props: {
      id: Number
    },
    created() {
      this.userId = localStorage.get('userID')
    },
    methods: {
      cancelStock() {
        this.$emit('closeDialog')
      },
      confirm() {
        let parmas = {
          id: this.id,
          reason: this.reason
        }
        let success = data => {
          if (data.code == 'OK') {
            this.reload()
            this.$message({
              type: 'success',
              message: '您已成功取消此客诉!'
            });
          } else {
            this.$message.error(data.msg)
          }
        }
        api.erpComplaintCancel(parmas, success)
      }
    }
  }
</script>
<style lang="scss" scoped>
  .complaintDelInfo {
    width: 500px;
    height: 450px;
    .com {
      line-height: 40px;
      background: #eee;
      text-align: center;
      margin-bottom: 20px;
    }
    .reason {
      margin: 0 100px;
      .el-textarea {
        width: 300px;
      }
    }
    .stockCon {
      width: 100%;
      text-align: center;
      padding-top: 100px;
    }
  }
</style>

